﻿using System;
using System.Windows.Forms;

namespace WindowsApplication2._5_字符串.生成字符串
{
    public partial class 生成字符串 : Form
    {
        public 生成字符串()
        {
            InitializeComponent();
        }

        /// <summary>
        /// c#
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string s = "";

            string s1 = this.richTextBox1.Text;
            string s2 = s1.Replace("\\", "\\\\");
            s2 = s2.Replace("\"", "\\\"");
            char[] split = new char[] { '\n' };

            string[] temp = s2.Split(split);
            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i].Trim().Length > 2)
                {
                    if (!temp[i].Trim().Substring(0, 2).Equals("//"))
                    {
                        s += "strTrans.Append(\"" + temp[i] + "\\n\");\n";
                    }
                    else
                    {
                        s += temp[i] + "\n";
                    }
                }
                else
                {
                    s += "strTrans.Append(\"" + temp[i] + "\\n\");\n";
                }
            }
            this.richTextBox2.Text = s;
        }

        /// <summary>
        /// c#
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            string s1 = this.richTextBox1.Text;
            s1 = s1.Replace("\\n", "\n");
            s1 = s1.Replace("\\t", "\t");
            s1 = s1.Replace("\\\"", "\"");
            this.richTextBox2.Text = s1;
        }

        /// <summary>
        /// php
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            string s = "";

            string s1 = this.richTextBox3.Text;
            string s2 = s1.Replace("\\", "\\\\");
            s2 = s2.Replace("\"", "\\\"");
            char[] split = new char[] { '\n' };

            string[] temp = s2.Split(split);
            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i].Trim().Length > 2)
                {
                    if (!temp[i].Trim().Substring(0, 2).Equals("//"))
                    {
                        s += "$strTemp.=\"" + temp[i] + "\\n\";\n";
                    }
                    else
                    {
                        s += temp[i] + "\n";
                    }
                }
                else
                {
                    s += "$strTemp.=\"" + temp[i] + "\\n\";\n";
                }
            }
            this.richTextBox4.Text = s;
        }

        /// <summary>
        /// php
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            string s1 = this.richTextBox3.Text;
            s1 = s1.Replace("\\n", "\n");
            s1 = s1.Replace("\\t", "\t");
            s1 = s1.Replace("\\\"", "\"");
            this.richTextBox4.Text = s1;
        }

        private void 生成字符串_Load(object sender, EventArgs e)
        {
        }
    }
}